﻿<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>能源环境事业部月度报表</title>
    <link href="../../Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="../../Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="../../Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="../../Content/themes/icon.css" rel="stylesheet" />
    <link href="../../Content/themes/table.css" rel="stylesheet" />
    <link href="../../Content/formstyles.css?v=1" rel="stylesheet" />
    <!--<script src="../../Scripts/jquery-easyui/Extension/jquery-easyui-datagridview/datagrid-detailview.js"></script>-->
    <script src="../../Content/js/common.js"></script>
    <script src="../../Scripts/jquery-easyui/Extension/jquery-easyui-datagridview/datagrid-detailview-ben.js"></script>
    <style> 
    .subRptTable table { 
       border-collapse:collapse;  
        border-spacing:0; 
        }
   .subRptTable td {
      background-color:#F5DEB3;
               padding:0;
      text-align: right;
        }
.datagrid-body  table{  
    border-collapse:collapse;  
    border: 1px solid #000000;  
}  

.datagrid-body  td{  
    border-collapse:collapse;  
    border: 1px solid #000000;  
}  
    </style>

</head>
<body> 
    <div id="ui_main_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false">
            <table id="ui_main_dg" data-options="fit:true,border:true" ></table> 
</div>  
    <script type="text/javascript"> 
    
        function ui_main_exportdata() {
            $.show_alert("消息", "功能待发布！"); 
        }

        $(function () {

            //ui_main_searchdata();
            $("#ui_main_dg").datagrid({       //初始化datagrid
                view: detailview,
                url: "/Rpt/nyhjmonthRpt?r=" + Math.random(),
                queryParams: { year: 2020, periodType: 'claimTime', status: 'all', rptType: 'yysr' },
                columns: [[
                { field: 'hasChild', title: '', width: 25, expander: true },//展开标记
                {
                    field: "项目", width: "220", title: "项目", align: 'left',
                    formatter: function (value, row, index) { return "<span style='white-space:pre; border:0px'>" + value + "</span>" },
 
                },
                { field: "行次", width: "40", title: "行次", align: 'center' },
                { field: "一月", width: "80", title: "一月", align: 'right', formatter: getCurrency, },
                { field: "二月", width: "80", title: "二月", align: 'right', formatter: getCurrency, },
                { field: "三月", width: "80", title: "三月", align: 'right', formatter: getCurrency, },
                { field: "四月", width: "80", title: "四月", align: 'right', formatter: getCurrency, },
                { field: "五月", width: "80", title: "五月", align: 'right', formatter: getCurrency, },
                { field: "六月", width: "80", title: "六月", align: 'right', formatter: getCurrency, },
                { field: "七月", width: "80", title: "七月", align: 'right', formatter: getCurrency, },
                { field: "八月", width: "80", title: "八月", align: 'right', formatter: getCurrency, },
                { field: "九月", width: "80", title: "九月", align: 'right', formatter: getCurrency, },
                { field: "十月", width: "80", title: "十月", align: 'right', formatter: getCurrency, },
                { field: "十一月", width: "80", title: "十一月", align: 'right', formatter: getCurrency, },
                { field: "十二月", width: "80", title: "十二月", align: 'right', formatter: getCurrency, },
                { field: "-", width: "80", title: "全年", align: 'right', formatter: function (value, row, index) { return "-" }, },
                ]],
                title: "能源环保事业部月度报表（营业收入）",
                pagination: false,
                rownumbers: false,
                fitcolumns: false,
                singleSelect: true,
                border: true,
                style: "border:1px solid; ",
                detailFormatter: function (index, row) {
                    return '<div id="ddv-' + index + '" style="padding:5px 0px 10px 190px"></div>';
                },
                //onLoadSuccess: function (data) { setTimeout(changeBorder("lines - both"), 1500); },
                onExpandRow: subDatatable,
               // onDblClickRow: subDatatable,                
               // onAfterRender: function (data) {  }
            });
            //setTimeout(changeBorder("lines - both"), 2500);
            
        });

        function subDatatable(index, row) {
                var htmlstr = "";
                switch (index) {
                    case 0:
                        $.getJSON('/Rpt/subMonthRptYYSR', {dept:'nyhb', year: 2018 }, function (data) {
                            htmlstr = "<table class='subRptTable'>";
                            $.each(data, function (InfoIndex, Info) {
                                htmlstr += "<tr>"
                                $.each(Info, function (i) {
                                    if (i == '项目') {
                                        htmlstr += "<td style='width:100px'>" + Info[i] + "</td>"
                                    } else {
                                        htmlstr += "<td style='width:80px'>" + Info[i].toFixed(2) + "</td>"
                                    }
                                })
                                htmlstr += "</tr>"
                            });
                            htmlstr += "</table>";
                            $('#ddv-' + index).html("");
                            $('#ddv-' + index).append(htmlstr);
                        });
                        break;
                    case 1:
                        $.getJSON('/Rpt/subMonthRptYYCB', { dept: 'nyhb', year: 2020 }, function (data) {
                            htmlstr = "<table class='subRptTable'>";
                            $.each(data, function (InfoIndex, Info) {
                                htmlstr += "<tr>"
                                $.each(Info, function (i) {
                                    if (i == '项目') {
                                        htmlstr += "<td style='width:100px'>" + Info[i] + "</td>"
                                    } else {
                                        htmlstr += "<td style='width:80px'>" + Info[i].toFixed(2) + "</td>"
                                    }
                                })
                                htmlstr += "</tr>"
                            });
                            htmlstr += "</table>";
                            $('#ddv-' + index).html("");
                            $('#ddv-' + index).append(htmlstr);
                        });

                        break;
                    case 3://销售费用
                        $.getJSON('/Rpt/getExpenseRpt?r=' + Math.random(), { dept: 'nyhb', type: 'xiaoshou', status: 'all', periodType: 'claimTime' }, function (data) {
                            htmlstr = "<table class='subRptTable'>";
                            $.each(data, function (InfoIndex, Info) {
                                htmlstr += "<tr>"
                                $.each(Info, function (i) {
                                    if (i == '项目') {
                                        var xm = Info[i];
                                        if ((xm.indexOf("销售费用") != -1)) {
                                            xm = xm.substring(4);
                                        }
                                        htmlstr += "<td style='width:100px'>" + xm + "</td>"
                                } else if ( i == '行次') {  }
                                    else {
                                        htmlstr += "<td style='width:80px'>" + Info[i].toFixed(2) + "</td>"
                                    }
                                })
                                htmlstr += "</tr>"
                            });
                            htmlstr += "</table>";
                            $('#ddv-' + index).html("");
                            $('#ddv-' + index).append(htmlstr);
                        });

                        break;
                    case 4://管理费用
                        $.getJSON('/Rpt/getExpenseRpt?r=' + Math.random(), { dept: 'nyhb', type: 'guanli', status: 'all', periodType: 'claimTime' }, function (data) {
                            htmlstr = "<table class='subRptTable'>";
                            $.each(data, function (InfoIndex, Info) {
                                htmlstr += "<tr>"
                                $.each(Info, function (i) {
                                    if (i == '项目') {
                                        var xm = Info[i];
                                        if ((xm.indexOf("管理费用") != -1)) {
                                            xm = xm.substring(4);
                                        }
                                        htmlstr += "<td style='width:100px'>" + xm + "</td>"
                                } else if ( i == '行次') {  }
                                    else {
                                        htmlstr += "<td style='width:80px'>" + Info[i].toFixed(2) + "</td>"
                                    }
                                })
                                htmlstr += "</tr>"
                            });
                            htmlstr += "</table>";
                            $('#ddv-' + index).html("");
                            $('#ddv-' + index).append(htmlstr);
                        });

                        break;
                    case 5://财务费用
                        $.getJSON('/Rpt/getExpenseRpt?r=' + Math.random(), { dept: 'nyhb', type: 'caiwu', status: 'all', periodType: 'claimTime' }, function (data) {
                            htmlstr = "<table class='subRptTable'>";
                            $.each(data, function (InfoIndex, Info) {
                                htmlstr += "<tr>"
                                $.each(Info, function (i) {
                                    if (i == '项目') {
                                        var xm = Info[i];
                                        if ((xm.indexOf("财务费用") != -1)) {
                                            xm = "贴息款";
                                        }
                                        htmlstr += "<td style='width:100px'>" + xm + "</td>"
                                    } else if (i == '行次') { }
                                    else {
                                        htmlstr += "<td style='width:80px'>" + Info[i].toFixed(2) + "</td>"
                                    }
                                })
                                htmlstr += "</tr>"
                            });
                            htmlstr += "</table>";
                            $('#ddv-' + index).html("");
                            $('#ddv-' + index).append(htmlstr);
                        });

                        break;
                    default:
                        break; 
                } 
                //    $('#ddv-' + index).panel({
                //        border: false,
                //        cache: false,
                //        href: '/Rpt/subMonthRpt?RptName=nyhj',
                //        onLoad: function () {
                //            $('#ui_main_dg').datagrid('fixDetailRowHeight', index);
                //        }
                //    });
                $('#ui_main_dg').datagrid('fixDetailRowHeight', index); 
        }


        </Script>
</div>    
</body>
    </html>
